from flask import jsonify

class HttpCode():
    ok = 200
    unautherror = 400
    paramserror = 401
    servererror = 500



def resful_result(code,message,data):
    return jsonify({"code":code,"message":message,"data":data or {}})


def success(message="",data=None):
    return resful_result(code=HttpCode.ok,message=message,data=data)

def unautherror(message="",data=None):
    return resful_result(code=HttpCode.unautherror,message=message,data=data)

def paraserror(message="",data=None):
    return resful_result(code=HttpCode.paramserror,message=message,data=data)

def servererror(message="",data=None):
    return  resful_result(code=HttpCode.servererror,message="服务器内部错误",data=data)
